package gui;

import java.util.Iterator;

import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;

import logic.Entry;
import logic.Row;

public abstract class RowPresentation {

	protected EntryPresentation ep;


	public abstract void preVisulize(final Row row, final JPanel panel);

	public abstract void postVisulize(final Row row, final JPanel panel);

	public JComponent visualize(Row row) {
		JPanel panel = new JPanel();
		panel.setName("row panel");

		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
		preVisulize(row,panel);
		for (Iterator<? extends Entry> colIterator = row.iterator(); colIterator
				.hasNext();) {
			panel.add(new JPanel());
			panel.add(ep.visulize(colIterator.next()));
			
		}
		postVisulize(row, panel);
		return panel;
	}
}
